﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace Shop.Extend
{
    public static class DataSetExt
    {
        #region 把DataSet转为Dictionary
        public static Dictionary<string, object> ToList(this DataSet ds)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("tableCount", ds.Tables.Count);
            for (int i = 0; i < ds.Tables.Count; i++)
            {
                DataTable dt = ds.Tables[i];
                dic.Add(dt.TableName,  dt.ToList() );
            }
            return dic;
        }
        #endregion
    }
}